{include file="admin@public/header" /}

<link href="/public/static/admin/blue/bills.css?ver=20210803202401" rel="stylesheet" type="text/css">

<script src="/public/static/admin/js/common/base.js"></script>
<link rel="stylesheet" href="/public/static/admin/easyui/layui-v2.6.8/css/layui.css">

<style type="text/css">
    .mod-toolbar-top strong.txt,
    #period {
        font-size: 14px;
        margin-right: 10px;
    }

    .ul-inline li label {
        vertical-align: middle;
    }

    .ul-inline li input {
        vertical-align: middle;
    }

    a.modeBtn {
        vertical-align: middle;
        width: 25px;
        height: 25px;
        display: inline-block;
        background: url("/css/img/ov_icons_2.png") no-repeat 0 0;
    }

    a.modeBtn.toPic.enable {
        background-position: -20px 2px;
    }

    a.modeBtn.toPic {
        background-position: 2px 2px;
    }

    a.modeBtn.toList.enable {
        background-position: -20px -22px;
    }

    a.modeBtn.toList {
        background-position: 2px -22px;
    }

    /*.cbox{background: #979292; font-size: 12px; color: #fff;  padding: 1px;  line-height: 12px;   border-radius: 3px;   z-index: 1;  border: 2px solid #fff;}*/
    /*.checked .cbox{background: #408BB5;}*/
    .container {
        margin: 0 15px;
        position: relative;
    }

    /*左侧分类栏样式*/
    #bsCategory {
        width: 200px;
        background: #fff;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        border: 1px solid #dedede;
        overflow: hidden;
    }

    #bsCategory h3 {
        background: #EEEEEE url(/css/default/img/ui-th.png) 0 0 repeat-x;
        border-bottom: 1px solid #dedede;
        color: #555;
        line-height: 30px;
        text-align: center;
    }

    /*右侧内容区样式*/
    /*.container .dataWrapper{ margin-left: 210px;}*/
    .container .dataWrapper {
        margin-top: 30px;
    }

    /*图片视图的样式*/
    #picGridWrap {
        background: #fff;
        padding: 10px;
        border: 1px solid #E4E3E3;
    }

    #picGridWrap .cbox {
        width: 20px;
        height: 20px;
        display: inline-block;
        background: url("/public/static/admin/css/img/ov_icons_1.png") no-repeat -1px 2px #fff;
        border-radius: 3px;
        z-index: 1;
    }

    #picGridWrap .cbox:hover {
        background-position: -27px 2px;
    }

    #picGridWrap .checked .cbox {
        background-position: -53px 2px;
    }

    #picGridWrap .groupchk .cbox {
        position: relative;
        top: 4px;
    }

    #picGridWrap .chkAll .cbox {
        position: relative;
        top: 4px;
    }

    #innerCenter a {
        float: none;
    }

    #innerRight {
        float: right;
    }

    #picGridWrap .changeBtns {
        background: #fff;
        padding: 0 0 10px 5px;
        border-bottom: 1px solid #E4E3E3;
        font-size: 12px;
    }

    #checkAll {
        margin-right: 10px;
        cursor: pointer;
    }

    #checkAll i {
        border: none;
        margin-right: 3px;
    }

    #sortDate {
        padding-right: 15px;
        cursor: pointer;
        /* margin-top: 3px; */
        z-index: 2;
        vertical-align: middle;
    }

    #sortDate:hover {
        color: #408BB5;
    }

    #sortDate.asc {
        background: url("/css/img/asc.png") no-repeat 52px 2px;
    }

    #sortDate.desc {
        background: url("/public/static/admin/css/img/desc.png") no-repeat 52px 2px;
    }

    #picGrid {
        overflow: auto;
        zoom: 1;
    }

    #picGrid .group h3 {
        font-size: 12px;
        font-weight: bold;
        padding-top: 15px;
        padding-left: 5px;
    }

    #picGrid .group h3 span:hover {
        cursor: pointer;
    }

    #picGrid .group h3 span i {
        margin: 0 5px;
        border: none;
    }

    #picGrid .list {
        padding: 10px 10px;
    }

    #picGrid .picItem {
        position: relative;
        float: left;
        width: 160px;
        height: 150px;
        border: 1px solid #ccc;
        margin: 5px;
        /*overflow: hidden;*/
    }

    #picGrid .picItem:hover {
        cursor: pointer;
        border-color: #408BB5;
    }

    #picGrid .picItem .itemInner {
        position: relative;
        height: 150px;
        width: 160px;
        zoom: 1;
    }

    #picGrid .picItem .itemInner .imgWrap {
        position: absolute;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        margin: auto;
    }

    #picGrid .picItem .img {
        max-width: 140px;
        max-height: 140px;
    }

    #picGrid .picItem img:hover {}

    #picGrid .picItem .imgWrap.first {
        top: 0;
        left: -6px;
        bottom: 10px;
        right: 0px;
        /*border: 2px solid #fff;*/
    }

    #picGrid .picItem .imgWrap.first .img {
        max-width: 140px;
        max-height: 110px;
    }

    #picGrid .picItem .imgWrap.second {
        top: 10px;
        left: 10px;
        bottom: 0;
        right: 0;
        border: 2px solid #fff;
    }

    #picGrid .picItem .imgWrap.second .img {
        max-width: 140px;
        max-height: 110px;
    }

    #picGrid .picItem .cbox {
        position: absolute;
        top: 5px;
        left: 5px;
    }

    #picGrid .picItem.selected {
        border-color: #408BB5;
    }

    #picGrid .picItem .tools {
        position: absolute;
        /*background: #ccc;*/
    }

    #picGrid .picItem .tools.top {
        right: 3px;
        top: 3px;
    }

    #picGrid .picItem .tools.top .btn {
        display: none;
        width: 25px;
        height: 25px;
        /*display: inline-block;*/
        background: url("/public//static/admin/css/img/ov_icons_1.png") no-repeat 0 0 #fff;
        border-radius: 3px;
        z-index: 1;
        border: none;
    }

    #picGrid .picItem .tools.top .split {
        background-position: 2px -41px;
    }

    #picGrid .picItem .tools.top .split:hover {
        background-position: -23px -41px;
    }

    #picGrid .picItem .tools.top .del {
        background-position: 2px -18px;
    }

    #picGrid .picItem .tools.top .del:hover {
        background-position: -23px -18px;
    }

    #picGrid .picItem:hover .tools.top .btn {
        display: inline-block;
    }

    #picGrid .picItem .tools.bottom {
        bottom: 0;
        background: #e1e1e1;
        width: 100%;
    }

    #picGrid .picItem .tools.bottom a {
        cursor: default;
        display: inline-block;
        padding: 0px 3px;
        color: #fff;
        border: 2px solid #fff;
    }

    #picGrid .picItem .tools .btn {
        cursor: pointer;
        color: #fff;
    }

    #picGrid .picItem .tools.bottom a {
        border: none;
        padding: 0 10px;
        color: #666;
    }

    #picGrid .picItem .tools.bottom .btn:hover {
        text-decoration: underline;
    }

    #picGrid .picItem .tools.bottom .cleanUp {
        float: right;
    }

    /*左侧树的特殊样式限制*/
    #ztree {
        width: 190px;
        overflow: auto;
    }

    #ztree_1_switch {
        display: none;
    }

    #ztree_1_ul {
        padding: 0;
    }

    /*生成凭证选项*/
    .createVoucherPop li {
        margin: -1px 0;
    }

    .createVoucherPop li a {
        width: 200px;
        margin: 0;
        cursor: pointer;
    }

    /*列表视图的样式*/
    .autoGrid {
        padding: 0;
    }

    .autoGrid tr.jqgroup td {
        padding: 5px;
    }

    #checkboxWrap {
        padding-left: 10px;
    }

    .picItem .bottom {
        text-align: center;
        height: 19px;
        line-height: 19px;
        overflow: hidden;
    }

    .layui-form-checkbox[lay-skin=primary] i {
        padding: 0;
    }

    .layui-form-checkbox[lay-skin=primary]:hover i {
        border-color: #5dc5e7;
    }

    .layui-form-checked[lay-skin=primary] i {
        background-color: #5dc5e7;
    }

    .group .list .picItem .itemInner .layui-form-checkbox[lay-skin=primary] i {
        position: absolute;
        top: 5px;
        left: 5px;
        z-index: 10;
        box-shadow: 0 0 5px 1px #fff;
    }

    .container .layui-form-checkbox[lay-skin=primary]:hover i {
        border-color: #3c8ab7;
    }

    .container .layui-form-checked[lay-skin=primary] i {
        background-color: #3c8ab7;
    }
</style>

<div class="wrapper">
    <form class="layui-form">
        <div class="mod-toolbar-top">
            <div class="fl">
                <ul class="ul-inline">
                    <li>
                        <span id="billType"></span>
                    </li>

                    <li id="checkboxWrap" style="padding-top: 8px;">
                        <!-- <label class="chk" style="margin-top:6px; "><input type="checkbox" name="box" value="isVoucher">已生成销售单</label>  -->
                        <input type="checkbox" name="isVoucher" lay-skin="primary" title="已生成销售单" id="isVoucher" {if
                            condition='$is_dj eq 1' }checked="checked" {/if} style="margin-top:6px; ">
                    </li>
                    <li><a class="ui-btn ui-btn-refresh" id="search" title="刷新"><b></b></a></li>
                </ul>
            </div>
            <div class="fr">

                <a class="ui-btn" id="uploadAttachment">导入附件</a>

                <a class="ui-btn ui-btn-sp" id="create">生成销货单</a>
            </div>
        </div>
        <div class="container">

            <div class="dataWrapper" id="picGridWrap">
                <p class="changeBtns">
                    <input type="checkbox" name="checkAll" lay-skin="primary" title="全选" lay-filter="allChoose"
                        style="margin-top:6px; " id="allChoose">
                    <span id="sortDate" {if condition="$order eq 0" }class="desc" {/if} title="{$order}">上传日期</span>
                </p>


                <!-- 图片列表 -->
                <div id="picGrid" style="height: 733.109px;">
                    {volist name="plist" id="vo" key="k"}
                    <div class="group">
                        <h3><input type="checkbox" name="dateChk" lay-skin="primary" title="{$vo.create_date}"
                                lay-filter="c_one" style="margin-top:6px; " id="timeAll-{$vo.create_date}"
                                class="cboxs-{$vo.create_date} date_box"></h3>
                        <ul class="list cf">
                            {volist name="list" id="v" }
                            {eq name="v['create_date']" value="$vo['create_date']"}
                            <li class="picItem">
                                <div class="itemInner">
                                    <span class="cboxWrap"><input type="checkbox" name="dateChkImg" data-id="{$v.id}"
                                            lay-skin="primary" lay-filter="c_img" data-date="{$vo.create_date}"
                                            class="imgcboxs-{$vo.create_date} imgimg"></span>
                                    <span class="imgWrap" style="width: 140px; height: 140px;text-align: center;">
                                        <img class="img" src="/public/uploads/{$v['path']}"
                                            href="/public/uploads/{$v['path']}">
                                    </span>
                                    <span class="tools top">
                                        <a class="del btn" data-id="{$v.id}"></a>
                                    </span>
                                </div>
                                <div class="tools bottom">{$v['path']}</div>
                            </li>
                            {/eq}
                            {/volist}
                        </ul>
                    </div>
                    {/volist}

                </div>



            </div>


        </div>
    </form>
</div>


<script type="text/javascript">

    $(document).ready(function () {

        var dete = "";
        layui.use('form', function () {
            var form = layui.form;
            //全选
            form.on('checkbox(allChoose)', function (data) {
                var a = data.elem.checked;
                if (a == true) {
                    $(".container :checkbox").prop("checked", true);
                    form.render('checkbox');
                } else {
                    $(".container :checkbox").prop("checked", false);
                    form.render('checkbox');
                }
            });



            //日期有一个未选中全选取消选中
            form.on('checkbox(c_one)', function (data) {
                //alert("111");
                var title = $(this).attr('title');
                var cboxs = '.cboxs-' + title;
                var imgcboxs = '.imgcboxs-' + title;
                var item = $(cboxs);

                for (var i = 0; i < item.length; i++) {
                    if (item[i].checked == false) {
                        $("#allChoose").prop("checked", false);
                        form.render('checkbox');
                        break;
                    }
                };
                var a = data.elem.checked;
                if (a == true) {
                    $(imgcboxs).prop("checked", true);
                    form.render('checkbox');
                } else {
                    $(imgcboxs).prop("checked", false);
                    form.render('checkbox');
                }
            });

            //图片有一个未选中全选取消选中
            form.on('checkbox(c_img)', function (data) {
                var title = $(this).attr('data-date');
                var cboxs = '.imgcboxs-' + title;
                var imgcboxs = '#timeAll-' + title;
                var item = $(cboxs);
                for (var i = 0; i < item.length; i++) {
                    if (item[i].checked == false) {
                        $("#allChoose").prop("checked", false);
                        $(imgcboxs).prop("checked", false);
                        form.render('checkbox');
                        break;
                    }
                }
            });



        });

        // 生成销货单
        $("#create").on("click", function () {
            // alert("11");
            var id_array = new Array();
            $('input:checkbox[name=dateChkImg]:checked').each(function () {
                id_array.push($(this).attr('data-id'));//向数组中添加元素  
            });
            if (id_array.length) {

            } else {
                layer.msg("请选择单据");
            }

            var tabid = 'salesOrder';
            var tabTxt = '销货单';
            var _href = '/sales/invsa/add.html?id_array=' + id_array;
            parent.tab.addTabItem({
                tabid: tabid,
                text: tabTxt,
                url: _href
            })

            // window.location.href="/sales/originalsaleslist/index.html?is_dj="+is_dj;
            console.log(id_array);
            // $.ajax({
            //     type: 'POST',
            //     url: "/sales/invsa/add.html",
            //     data: { id_array: id_array},
            //     dataType: "json",
            //     async: false,
            //     error: function (request) {
            //         layer.msg("发送请求失败！");
            //     },
            //     success: function (data) {
            //         if (data.status == 1) {
            //             layer.msg(data.msg);
            //             window.location.reload();
            //         } else {
            //             layer.msg(data.msg);
            //         }

            //     }
            // });
        });


        // 排序
        $("#sortDate").on("click", function () {
            var order = $(this).attr('title');
            if (order == 0) {
                order = 1;
            } else {
                order = 0;
            }
            var is_dj = 0;
            if ($("#isVoucher").get(0).checked) {
                is_dj = 1;
            } else {
                is_dj = 0;
            }
            window.location.href = "/sales/originalsaleslist/index.html?order=" + order + "&is_dj=" + is_dj;
        });


        // 刷新
        $("#search").on("click", function () {
            var is_dj = 0;
            if ($("#isVoucher").get(0).checked) {
                is_dj = 1;
            } else {
                is_dj = 0;
            }
            window.location.href = "/sales/originalsaleslist/index.html?is_dj=" + is_dj;
            //layer.msg(is_dj);
        });
        // 删除
        $(".del").on("click", function () {
            var id = $(this).attr("data-id");
            //alert(id);
            layer.confirm('您确定要删除吗？', {
                btn: ['确定', '取消'], //按钮
                title: "删除提示",
            }, function () {
                // layer.msg('确定');
                $.ajax({
                    type: 'POST',
                    url: "del.html",
                    data: { id: id },
                    dataType: "json",
                    async: false,
                    error: function (request) {
                        layer.msg("发送请求失败！");
                    },
                    success: function (data) {
                        if (data.status == 1) {
                            layer.msg(data.msg);
                            window.location.reload();
                        } else {
                            layer.msg(data.msg);
                        }

                    }
                });
            }, function () {
                // layer.msg('取消');
            });
        });


        // 导入附件
        $("#uploadAttachment").on("click", function () {

            var url = "/sales/originalsaleslist/add.html"
            layer.open({
                type: 2,
                title: "导入附件",
                shadeClose: true,
                shade: 0.3,
                maxmin: true, //开启最大化最小化按钮
                area: ['600px', '400px'],
                fixed: false, //不固定
                btn: ['确定', '取消'],
                content: url,
                btn1: function (index, layero) {
                    var body = layer.getChildFrame('body', index);
                    //var obj = $(layero).find("iframe")[0].contentWindow.body_files;    //obj可以调用子页面的任何方法
                    var body_data = $(layero).find("iframe")[0].contentWindow.formData();

                    console.log(body_data.body_files);
                    if (body_data.body_files == null) {
                        layer.msg("请上传附件");
                        return false;
                    } else {
                        var formData = new FormData();
                        var fileObj = body_data.body_files;
                        var fileObj_64 = body_data.body_files_64;
                        var length = fileObj.length;
                        formData.append('image', fileObj_64);
                        formData.append('path', "pz");
                        formData.append('type', "1");
                        $.ajax({
                            url: '/admin/basic/baseimgs_upload.html',
                            dataType: 'json',
                            type: 'POST',
                            async: false,
                            data: formData,
                            processData: false, // 使数据不做处理
                            contentType: false, // 不要设置Content-Type请求头
                            success: function (res) {
                                if (res.status == 1) {
                                    layer.msg(res.msg);
                                    layer.close(index);
                                    sleep(1);
                                    window.location.reload();
                                } else {
                                    alert(res.msg);
                                }
                            },
                            error: function (response) {
                                alert("接口错误");
                            }
                        });


                        return false;
                    }
                },
                btn2: function (index, layero) {
                    layer.close(index);
                    return false;
                }

            });
        });

    });

</script>


{include file="admin@public/footer" /}